clear all; close all; clc;

R = 220;
C =33e-12;
L=100e-6;
RC=R*C;



f0=1/(2*pi*sqrt(L*C));
T = 1/ (10000*f0);
t = 0:T:(15*1/f0);
it=length(t);

Uc = nan(1, it);
Ul = nan(1, it);
dUc = nan(1, it);
i = nan(1, it);
di = nan(1, it);

stdn=sqrt(13);
E=stdn*randn(1,it);

Uc(1)=0; 
i(1)=0;
di(1)=0;
Ul(1)=di(1)*L;


for k = 2:it

    Ul(k)=E(k)-i(k-1)*R-Uc(k-1);
    di(k)=Ul(k)/L;
    i(k)=i(k-1)+di(k-1)*T;
    dUc(k)=i(k)/C;
    Uc(k)=Uc(k-1)+dUc(k)*T;
    
end
U=Uc;

figure(1);
s=plot(t*1e9, [E; U]);
xlabel('t, ns');
ylabel('U_c,E,U, Volt');
legend('U_c(t))','E(t)','U(t)')
%set(s,'Color','red','LineWidth',2)
grid on;

figure(2);
plot(t*1e9, [E; U]);
xlabel('t, ns');
ylabel('U_c,E,U, Volt');
legend('U_c(t))','E(t)','U(t)')
%set(s,'Color','red','LineWidth',2)
grid on;


